

#import "UIImage+Resize.h"

@implementation UIImage (Resize)


+(UIImage *)resizableImage:(NSString *)imageName
{
    UIImage *oldImage = [UIImage imageNamed:imageName];
    
    CGFloat w = oldImage.size.width/2;
    CGFloat h = oldImage.size.height/2;
    UIImage *newImage = [oldImage resizableImageWithCapInsets:UIEdgeInsetsMake(h, w, h, w)];
    return newImage;
    
}

/// UIImage和base64互转
- (NSString*)encodeToBase64StringPng {
    return [UIImagePNGRepresentation(self) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
}
- (NSString *)encodeToBase64StringJpeg:(CGFloat)compressionQuality {
    return [UIImageJPEGRepresentation(self, compressionQuality) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
}
+ (UIImage *)decodeBase64ToImage:(NSString *)strEncodeData {
    NSData *data = [[NSData alloc] initWithBase64EncodedString:strEncodeData options:NSDataBase64DecodingIgnoreUnknownCharacters];
    return [UIImage imageWithData:data];
}

@end
